<?php
/**
 * 上传文件管理
 * User: raisound
 * Date: 2021/10/13
 */
namespace app\api\controller;

use app\api\business\CommonBus as CommonBus;
use app\common\lib\Str;
use app\common\model\redis\RedisModel;
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
use \PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use \PhpOffice\PhpSpreadsheet\IOFactory;
use think\facade\Db;
class Upload extends AuthBase
{
    public function picture(){
        try {
            $file = request()->file('file');
            // 上传到本地服务器
            $savename = \think\facade\Filesystem::putFile( 'topic', $file);
            if($savename){
                $img = '/public/storage/'.$savename;
                return returnResult(config("config.code.success"),config("config.describe.success"),$img);
            }else{
                return returnResult(config("config.code.success"),'上传失败！',[]);
            }
        }catch (\Exception $e){
            logWrite('picture', $e->getMessage(), __FILE__ );
            return returnResult(config("config.code.error"), $e->getMessage());
        }
    }

}